<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./vue.global.js"></script>
</head>
<body>
    <div id="app">
        <my-head>
            <h2>logo<br>,message可以获取到：{{message}}<br> ,title获取不到: {{title}}</h2>
        </my-head>
    </div>
    <script>
        let app = Vue.createApp({
            //message作用域为根组件
            data(){
                return {
                    message:'hello app world'
                }
            }
        })

        app.component(
            'MyHead',
            {
                data(){
                    return {
                        title:'hello MyHead world'
                    }
                },
                //title只能在子组件内部使用
                template: `
                <header>
                    <slot></slot>
                    <ul>
                        <li>首页:{{title}}</li>
                        <li>视频</li>
                        <li>音乐</li>
                    </ul>
                </header>
                `,

            })

        let vm = app.mount('#app');
    </script>

</body>
</html>